﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
                    xmlns:Converters="clr-namespace:MahApps.Metro.Converters">

    <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <Converters:ThicknessToDoubleConverter x:Key="ThicknessToDoubleConverter" />

    <!--TextBox Style-->
    <Style TargetType="{x:Type TextBox}"
           x:Key="MetroTextBox">
        <Setter Property="ContextMenu"
                Value="{DynamicResource TextBoxMetroContextMenu}" />
        <Setter Property="Controls:TextboxHelper.IsMonitoring"
                Value="True" />
        <Setter Property="Controls:ControlsHelper.ButtonWidth"
                Value="22" />
        <Setter Property="SelectionBrush"
                Value="{DynamicResource HighlightBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource ContentFontFamily}" />
        <Setter Property="FontSize"
                Value="{DynamicResource ContentFontSize}" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="MinHeight"
                Value="26" />
        <Setter Property="Background"
                Value="{DynamicResource ControlBackgroundBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="Padding"
                Value="0" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="Controls:TextboxHelper.FocusBorderBrush"
                Value="{DynamicResource TextBoxFocusBorderBrush}" />
        <Setter Property="Controls:TextboxHelper.MouseOverBorderBrush"
                Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
        <!-- change SnapsToDevicePixels to True to view a better border and validation error -->
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="Validation.ErrorTemplate"
                Value="{DynamicResource ValidationErrorTemplate}" />
        <Setter Property="CaretBrush"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="enterGotFocus">
                            <DoubleAnimation Duration="0:0:0.2"
                                             To=".2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                        <Storyboard x:Key="exitGotFocus">
                            <DoubleAnimation Duration="0:0:0.2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>

                        <Storyboard x:Key="enterHasText">
                            <DoubleAnimation Duration="0:0:0.2"
                                             From=".2"
                                             To="0"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                        <Storyboard x:Key="exitHasText">
                            <DoubleAnimation Duration="0:0:0.2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Rectangle x:Name="Base"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}"
                                   Fill="{TemplateBinding Background}" />
                        <Rectangle x:Name="FocusRectangle"
                                   Visibility="Collapsed"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}" />
                        <Grid x:Name="PART_InnerGrid"
                              Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition x:Name="ButtonColumn"
                                                  Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ButtonWidth), Mode=OneWay}" />
                            </Grid.ColumnDefinitions>

                            <Border x:Name="ReadOnlyVisualElement"
                                    Grid.ColumnSpan="2"
                                    Background="{x:Null}"
                                    Opacity="0" />
                            <ScrollViewer x:Name="PART_ContentHost"
                                          Grid.Column="0"
                                          BorderThickness="0"
                                          IsTabStop="False"
                                          Margin="2"
                                          VerticalAlignment="Stretch"
                                          Background="{x:Null}" />
                            <TextBlock x:Name="Message"
                                       Grid.Column="0"
                                       Text="{TemplateBinding Controls:TextboxHelper.Watermark}"
                                       Padding="{TemplateBinding Padding}"
                                       Visibility="Collapsed"
                                       Foreground="{TemplateBinding Foreground}"
                                       IsHitTestVisible="False"
                                       Opacity="0.6"
                                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                       Margin="6,2,6,2" />
                            <Button x:Name="PART_ClearText"
                                    Grid.Column="1"
                                    Style="{DynamicResource ChromelessButtonStyle}"
                                    FontSize="16"
                                    Foreground="{TemplateBinding Foreground}"
                                    FontFamily="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ButtonFontFamily), Mode=OneWay}"
                                    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ButtonContent), Mode=OneWay}"
                                    Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ClearTextButton), Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}"
                                    IsTabStop="False" />
                        </Grid>
                        <Rectangle x:Name="DisabledVisualElement"
                                   Stroke="{DynamicResource ControlsDisabledBrush}"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                                     Value="">
                            <Setter TargetName="Message"
                                    Property="Visibility"
                                    Value="Visible" />
                        </DataTrigger>

                        <!-- multiline textbox cannot bind to actual height so take the fallbach button width -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TextWrapping"
                                           Value="NoWrap" />
                                <Condition Property="AcceptsReturn"
                                           Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="ButtonColumn"
                                    Property="Width"
                                    Value="{Binding ElementName=PART_InnerGrid, Path=ActualHeight, Mode=OneWay}" />
                        </MultiTrigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=(Controls:TextboxHelper.ClearTextButton)}"
                                     Value="False">
                            <Setter TargetName="PART_ContentHost"
                                    Property="Grid.ColumnSpan"
                                    Value="2" />
                            <Setter TargetName="Message"
                                    Property="Grid.ColumnSpan"
                                    Value="2" />
                        </DataTrigger>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter TargetName="DisabledVisualElement"
                                    Property="Opacity"
                                    Value="0.6"/>
                        </Trigger>
                        <Trigger Property="IsReadOnly"
                                 Value="True">
                            <Setter TargetName="ReadOnlyVisualElement"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.FocusBorderBrush)}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText"
                                 Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="PART_ClearText"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush8}" />
                            <Setter TargetName="PART_ClearText"
                                    Property="Foreground"
                                    Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText"
                                 Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="PART_ClearText"
                                    Property="Background"
                                    Value="{DynamicResource BlackBrush}" />
                            <Setter TargetName="PART_ClearText"
                                    Property="Foreground"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Controls:TextboxHelper.HasText"
                                           Value="False" />
                                <Condition Property="IsFocused"
                                           Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource enterGotFocus}" />
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource exitGotFocus}" />
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>

                        <Trigger Property="Controls:TextboxHelper.HasText"
                                 Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource enterHasText}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource exitHasText}" />
                            </Trigger.ExitActions>
                        </Trigger>

                        <Trigger Property="Controls:TextboxHelper.IsWaitingForData"
                                 Value="True">
                            <Setter TargetName="Base"
                                    Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                                      Color="{DynamicResource BlackColor}"
                                                      Opacity="0"
                                                      BlurRadius="10" />
                                </Setter.Value>
                            </Setter>
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation From="0"
                                                         To="1"
                                                         Storyboard.TargetName="Base"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:02"
                                                         AutoReverse="True"
                                                         RepeatBehavior="Forever" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="Controls:TextboxHelper.IsWaitingForData"
                                 Value="False">
                            <Setter TargetName="Base"
                                    Property="Effect"
                                    Value="{x:Null}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TextBox}"
           BasedOn="{StaticResource MetroTextBox}"
           x:Key="MetroButtonTextBox">
        <Setter Property="Controls:TextboxHelper.ButtonTemplate"
                Value="{DynamicResource ChromelessButtonTemplate}" />
        <!-- change SnapsToDevicePixels to True to view a better border and validation error -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="enterGotFocus">
                            <DoubleAnimation Duration="0:0:0.2"
                                             To=".2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                        <Storyboard x:Key="exitGotFocus">
                            <DoubleAnimation Duration="0:0:0.2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>

                        <Storyboard x:Key="enterHasText">
                            <DoubleAnimation Duration="0:0:0.2"
                                             From=".2"
                                             To="0"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                        <Storyboard x:Key="exitHasText">
                            <DoubleAnimation Duration="0:0:0.2"
                                             Storyboard.TargetProperty="Opacity"
                                             Storyboard.TargetName="Message" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Rectangle x:Name="Base"
                                   Stroke="{TemplateBinding BorderBrush}"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}"
                                   Fill="{TemplateBinding Background}" />
                        <Rectangle x:Name="FocusRectangle"
                                   Visibility="Collapsed"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}" />
                        <Grid x:Name="PART_InnerGrid"
                              Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition x:Name="ButtonColumn"
                                                  Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ButtonWidth), Mode=OneWay}" />
                            </Grid.ColumnDefinitions>

                            <Border x:Name="ReadOnlyVisualElement"
                                    Grid.ColumnSpan="2"
                                    Background="{x:Null}"
                                    Opacity="0" />
                            <ScrollViewer x:Name="PART_ContentHost"
                                          Grid.Column="0"
                                          BorderThickness="0"
                                          IsTabStop="False"
                                          Margin="2"
                                          VerticalAlignment="Stretch"
                                          Background="{x:Null}" />
                            <TextBlock x:Name="Message"
                                       Grid.Column="0"
                                       Text="{TemplateBinding Controls:TextboxHelper.Watermark}"
                                       Padding="{TemplateBinding Padding}"
                                       Visibility="Collapsed"
                                       Foreground="{TemplateBinding Foreground}"
                                       IsHitTestVisible="False"
                                       Opacity="0.6"
                                       HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                       Margin="6,2,6,2" />
                            <Button x:Name="PART_ClearText"
                                    Grid.Column="1"
                                    Style="{DynamicResource ChromelessButtonStyle}"
                                    FontSize="16"
                                    Foreground="{TemplateBinding Foreground}"
                                    FontFamily="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ButtonFontFamily), Mode=OneWay}"
                                    Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ButtonContent), Mode=OneWay}"
                                    Template="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.ButtonTemplate), Mode=OneWay}"
                                    IsTabStop="False" />
                        </Grid>
                        <Rectangle x:Name="DisabledVisualElement"
                                   Stroke="{DynamicResource ControlsDisabledBrush}"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   IsHitTestVisible="False"
                                   Opacity="0" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}"
                                     Value="">
                            <Setter TargetName="Message"
                                    Property="Visibility"
                                    Value="Visible" />
                        </DataTrigger>

                        <!-- multiline textbox cannot bind to actual height so take the fallbach button width -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="TextWrapping"
                                           Value="NoWrap" />
                                <Condition Property="AcceptsReturn"
                                           Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="ButtonColumn"
                                    Property="Width"
                                    Value="{Binding ElementName=PART_InnerGrid, Path=ActualHeight, Mode=OneWay}" />
                        </MultiTrigger>

                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter TargetName="DisabledVisualElement"
                                    Property="Opacity"
                                    Value="0.6" />
                        </Trigger>
                        <Trigger Property="IsReadOnly"
                                 Value="True">
                            <Setter TargetName="ReadOnlyVisualElement"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.FocusBorderBrush)}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText"
                                 Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="PART_ClearText"
                                    Property="Background"
                                    Value="{DynamicResource GrayBrush8}" />
                            <Setter TargetName="PART_ClearText"
                                    Property="Foreground"
                                    Value="{DynamicResource AccentColorBrush}" />
                        </Trigger>
                        <Trigger SourceName="PART_ClearText"
                                 Property="IsPressed"
                                 Value="True">
                            <Setter TargetName="PART_ClearText"
                                    Property="Background"
                                    Value="{DynamicResource BlackBrush}" />
                            <Setter TargetName="PART_ClearText"
                                    Property="Foreground"
                                    Value="{DynamicResource WhiteBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type TextBox}"
           BasedOn="{StaticResource MetroButtonTextBox}"
           x:Key="ButtonCommandMetroTextBox" />

    <Style TargetType="{x:Type TextBox}"
           x:Key="SearchMetroTextBox"
           BasedOn="{StaticResource MetroButtonTextBox}">
        <Setter Property="Controls:TextboxHelper.ButtonTemplate">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid Background="{TemplateBinding Background}">
                        <Grid x:Name="contentPresenter"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                              Opacity="0.75">
                            <Canvas Width="15"
                                    Height="15"
                                    Clip="F1 M 0,0L 48,0L 48,48L 0,48L 0,0">
                                <!-- x:Key="appbar_magnify"-->
                                <Path Width="15.7781"
                                      Height="15.7781"
                                      Stretch="Fill"
                                      Fill="{TemplateBinding Foreground}"
                                      Data="F1 M 14.8076,31.1139L 20.0677,25.9957C 19.3886,24.8199 19.25,23.4554 19.25,22C 19.25,17.5817 22.5817,14 27,14C 31.4183,14 35,17.5817 35,22C 35,26.4183 31.4183,29.75 27,29.75C 25.6193,29.75 24.3204,29.6502 23.1868,29.0345L 17.8861,34.1924C 17.105,34.9734 15.5887,34.9734 14.8076,34.1924C 14.0266,33.4113 14.0266,31.895 14.8076,31.1139 Z M 27,17C 24.2386,17 22,19.2386 22,22C 22,24.7614 24.2386,27 27,27C 29.7614,27 32,24.7614 32,22C 32,19.2386 29.7614,17 27,17 Z " />
                            </Canvas>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsMouseOver"
                                 Value="False">
                            <Setter TargetName="contentPresenter"
                                    Property="Opacity"
                                    Value=".5" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MetroRichTextBox"
           TargetType="{x:Type RichTextBox}">
        <Style.Resources>
            <Style TargetType="{x:Type Hyperlink}"
                   BasedOn="{StaticResource {x:Type Hyperlink}}">
                <Setter Property="Foreground"
                        Value="{DynamicResource AccentColorBrush}" />
                <Setter Property="TextDecorations"
                        Value="Underline" />
                <Style.Triggers>
                    <Trigger Property="IsMouseOver"
                             Value="True">
                        <Setter Property="Foreground"
                                Value="{DynamicResource HighlightBrush}" />
                    </Trigger>
                    <Trigger Property="IsEnabled"
                             Value="False">
                        <Setter Property="Foreground"
                                Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                    </Trigger>
                    <Trigger Property="IsEnabled"
                             Value="True">
                        <Setter Property="Cursor"
                                Value="Hand" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
        <Setter Property="ContextMenu"
                Value="{DynamicResource TextBoxMetroContextMenu}" />
        <Setter Property="SelectionBrush"
                Value="{DynamicResource HighlightBrush}" />
        <Setter Property="FontFamily"
                Value="{DynamicResource ContentFontFamily}" />
        <Setter Property="FontSize"
                Value="{DynamicResource ContentFontSize}" />
        <Setter Property="BorderThickness"
                Value="1" />
        <Setter Property="MinHeight"
                Value="26" />
        <Setter Property="MinWidth"
                Value="10" />
        <Setter Property="Background"
                Value="{DynamicResource ControlBackgroundBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource TextBrush}" />
        <Setter Property="BorderBrush"
                Value="{DynamicResource TextBoxBorderBrush}" />
        <Setter Property="Controls:TextboxHelper.FocusBorderBrush"
                Value="{DynamicResource TextBoxFocusBorderBrush}" />
        <Setter Property="Controls:TextboxHelper.MouseOverBorderBrush"
                Value="{DynamicResource TextBoxMouseOverBorderBrush}" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="AllowDrop"
                Value="True" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="ScrollViewer.PanningMode"
                Value="VerticalFirst" />
        <Setter Property="Stylus.IsFlicksEnabled"
                Value="False" />
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBoxBase}">
                    <Grid>
                        <Border x:Name="Bd"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Background="{TemplateBinding Background}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ScrollViewer x:Name="PART_ContentHost"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                        <Rectangle x:Name="FocusRectangle"
                                   Visibility="Collapsed"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Stroke="{DynamicResource ControlsDisabledBrush}"
                                   StrokeThickness="{TemplateBinding BorderThickness, Converter={StaticResource ThicknessToDoubleConverter}}"
                                   Fill="{DynamicResource ControlsDisabledBrush}"
                                   Opacity="0.6"
                                   IsHitTestVisible="False"
                                   Visibility="Collapsed" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.MouseOverBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsFocused"
                                 Value="True">
                            <Setter TargetName="FocusRectangle"
                                    Property="Visibility"
                                    Value="Visible" />
                            <Setter TargetName="FocusRectangle"
                                    Property="Stroke"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:TextboxHelper.FocusBorderBrush)}" />
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter TargetName="DisabledVisualElement"
                                    Property="Visibility"
                                    Value="Visible" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>